package com.zhuoshi.dao;

import java.util.List;

import org.springframework.orm.hibernate5.HibernateTemplate;

import com.zhuoshi.entity.User;

public class UserDaoImpl implements UserDao{
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
	private HibernateTemplate hibernateTemplate;
	@Override
	public void add() {
		System.out.println("dao............");
		User user=new User();
		user.setUsername("zsan");
		user.setPassword("123");
		hibernateTemplate.save(user);
	}
	@Override
	public void selectAll() {
		String hql="from User where uid=?";
		List<User> users=(List<User>) hibernateTemplate.find(hql,1);
		System.out.println(users.size());
		for (User user : users) {
			System.out.println(user);
		}
	}

}
